def foo():
    print("starting...")
    count=0
    while True:
        count+=1
        res = yield count
        print("res:",res)

def foo2(batch_size=10):
    print("starting...")
    count=0
    while True:
        count+=1+batch_size
        res = yield count
        print("res:",res)
g = foo2(batch_size=10)
print(next(g))
print("----------")
print(next(g))
print("----------")
print(next(g))
print("----------")


class Animal:
    def __init__(self, animal_list):
        self.animals_name = animal_list
        self.an_len=len(self.animals_name)

    def __getitem__(self, index):
        idx=index % self.an_len
        return self.animals_name[idx]

animals = Animal(["dog","cat","fish"])
for i in range(10):
    print(animals.__getitem__(i))
# for animal in animals:
#     print(animal)

